﻿
        var tab = null;
        var accordion = null;
        var tree = null;
        $(function () {

            //菜单
            $("#pageloading").height($(window).height());

            //布局
            $("#layout1").ligerLayout({ leftWidth: 190, height: '100%', onHeightChanged: f_heightChanged });

            var height = $(".l-layout-center").height();
            //Tab
            tab = $("#framecenter").ligerTab({ height: height });
            $("#currentTabID").val(tab.getSelectedTabItemID());  //获取当前tablid
            //面板
            accordion = $("#accordion1").ligerAccordion({ height: height - 24, speed: null });

            $(".l-link").hover(function () {
                $(this).addClass("l-link-over");
            }, function () {
                $(this).removeClass("l-link-over");
            });
            var trees = $(".tree1").each(function (index) {
                tree = $(this).ligerTree({
                    checkbox: false,
                    nodeWidth: 120,
                    attribute: ['nodename', 'url'],
                    onSelect: function (node) {
                        if (!node.data.url) return;
                        var tabid = $(node.target).attr("tabid");

                        if (!tabid) {
                            tabid = new Date().getTime();
                            $(node.target).attr("tabid", tabid);

                        }
                        $("#currentTabID").val(tabid);
                        if ($(">ul >li", tab.tab.links).length > 10) {
                            var currentTabid = $("li.l-selected", tab.tab.links).attr("tabid"); //当前选择的tabid
                            if (currentTabid == "home") return;
                            tab.overrideTabItem(currentTabid, { tabid: tabid, url: node.data.url, text: node.data.text });
                            return;
                        }
                        f_addTab(tabid, node.data.text, node.data.url);
                        //old method 
                        //
                        //                    $("iframe").bind({
                        //                        "readystatechange": function () {
                        //                            if (this.readyState == 'complete') {
                        //                                $("#pageloading").hide();
                        //                            }
                        //                        }
                        //                    });
                        //new method 支持多浏览器
                        var curiframe = $("#" + "f_" + $("#currentTabID")[0].value)[0];
                        if (curiframe.attachEvent) {
                            curiframe.attachEvent("onload", function () {
                                $("#pageloading").hide();
                            });
                        } else {
                            curiframe.onload = function () {
                                $("#pageloading").hide();
                            };
                        }
                        //
                    }
                });
            });
            $("#pageloading").hide();
        });

        function f_heightChanged(options) {
            if (tab)
                tab.addHeight(options.diff);
            if (accordion && options.middleHeight - 24 > 0)
                accordion.setHeight(options.middleHeight - 24);
        }
        function f_addTab(tabid, text, url) {

            tab.addTabItem({ tabid: tabid, text: text, url: url });

        }
        